package main;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import stockGP.StockGP;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {


		//initializing variables

		boolean isTrain=true;
		int numDays=10;
		String modelFile="model.txt", filenames="filenames.txt", datafolder="financialdata";


		BufferedReader br = null;
		BufferedReader brr = null;

		if(isTrain)
		{
			StockGP gp = new StockGP();
			String str2=null;
			try 
			{

				brr=new BufferedReader(new FileReader(filenames));

				ArrayList<Stock> stocks=new ArrayList<Stock>();

				ArrayList<Double> prices;
				String str;
				// as long as the file has more lines to read
				while ((str = brr.readLine()) != null)
				{
					br=new BufferedReader(new FileReader(datafolder+"/"+str));
					prices=new ArrayList<Double>();
					String name="";
					while((str2=br.readLine()) != null)
					{
						String [] splitted=str2.split(",");
						name=splitted[0];
						prices.add(Double.parseDouble(splitted[5]));
					}
					stocks.add(new Stock(name,prices));
					br.close();
				}


				
				brr.close();
				
				//printing the date of beginning of the algorithm
				System.out.println(new java.util.Date());


				//running random algorithm for monkey problem
				gp.run_alg(stocks,numDays);


				//printing date of finish
				System.out.println(new java.util.Date());

			}
			catch (Exception e)
			{
				e.printStackTrace();
				System.out.println("problem");
			}
		}
	}
}